package com.ruoyi.web.wx.controller;

import java.util.List;

import com.ruoyi.web.wx.entity.CashOut;
import com.ruoyi.web.wx.entity.CashOutVO;
import com.ruoyi.web.wx.entity.WxUserVO;
import com.ruoyi.web.wx.service.ICashOutService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;

/**
 * 提现记录 信息操作处理
 * 
 * @author ruoyi
 * @date 2019-08-27
 */
@Controller
@RequestMapping("/system/cashOut")
public class CashOutController extends BaseController
{
    private String prefix = "system/cashOut";
	
	@Autowired
	private ICashOutService cashOutService;
	
	@RequiresPermissions("system:cashOut:view")
	@GetMapping()
	public String cashOut()
	{
	    return prefix + "/cashOut";
	}
	
	/**
	 * 查询提现记录列表
	 */
	@RequiresPermissions("system:cashOut:list")
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(WxUserVO wxUserVO)
	{
		startPage();
        //List<CashOut> list = cashOutService.selectCashOutList(cashOut);
        List<WxUserVO> list = cashOutService.selectCashOutList1(wxUserVO);
		return getDataTable(list);
	}
	
	
	/**
	 * 导出提现记录列表
	 */
	@RequiresPermissions("system:cashOut:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(CashOut cashOut)
    {
    	List<CashOut> list = cashOutService.selectCashOutList(cashOut);
        ExcelUtil<CashOut> util = new ExcelUtil<CashOut>(CashOut.class);
        return util.exportExcel(list, "cashOut");
    }
	
	/**
	 * 新增提现记录
	 */
	@GetMapping("/add")
	public String add()
	{
	    return prefix + "/add";
	}
	
	/**
	 * 新增保存提现记录
	 */
	@RequiresPermissions("system:cashOut:add")
	@Log(title = "提现记录", businessType = BusinessType.INSERT)
	@PostMapping("/add")
	@ResponseBody
	public AjaxResult addSave(CashOut cashOut)
	{		
		return toAjax(cashOutService.insertCashOut(cashOut));
	}

	/**
	 * 修改提现记录
	 */
	@GetMapping("/edit/{ id}")
	public String edit(@PathVariable(" id") String  id, ModelMap mmap)
	{
		CashOutVO cashOutVO = cashOutService.selectCashOutById( id);
		mmap.put("cashOut", cashOutVO);
	    return prefix + "/edit";
	}
	
	/**
	 * 修改保存提现记录
	 */
	@RequiresPermissions("system:cashOut:edit")
	@Log(title = "提现记录", businessType = BusinessType.UPDATE)
	@PostMapping("/edit")
	@ResponseBody
	public AjaxResult editSave(CashOut cashOut)
	{		
		return toAjax(cashOutService.updateCashOut(cashOut));
	}
	
	/**
	 * 删除提现记录
	 */
	@RequiresPermissions("system:cashOut:remove")
	@Log(title = "提现记录", businessType = BusinessType.DELETE)
	@PostMapping( "/remove")
	@ResponseBody
	public AjaxResult remove(String ids)
	{		
		return toAjax(cashOutService.deleteCashOutByIds(ids));
	}
	
}
